<?php


namespace App\Models;


use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class WarrantySync extends Model
{
    use SoftDeletes;

    const PUSH_U8 = 1;
    public static $system_types = [
        self::PUSH_U8 => "同步到U8"
    ];

    const CYCLE_HALF_HOUR = 1; //半小时
    const CYCLE_ONE_WEEK = 2; //一周

    public static $cycles = [
        self::CYCLE_HALF_HOUR => "0.5小时",
        self::CYCLE_ONE_WEEK => "一周",
    ];

    const SYNC_STATUS_DEFAULT = 0;
    const SYNC_STATUS_ING = 1;
    const SYNC_STATUS_SUCCESS = 2;
    const SYNC_STATUS_FAIL = 3;

    public static $sync_status = [
        self::SYNC_STATUS_DEFAULT => "待同步",
        self::SYNC_STATUS_ING => "同步中",
        self::SYNC_STATUS_SUCCESS => "成功",
        self::SYNC_STATUS_FAIL => "失败",
    ];

    const STATUS_ENABLE = 1;
    const STATUS_DISABLE = 2;

    public static $status = [
        self::STATUS_ENABLE => "启用",
        self::STATUS_DISABLE => "暂停",
    ];

    protected $table = 'warranty_sync';
    protected $primaryKey = 'id';

    public function getSystemTypeValue(): string
    {
        return self::$system_types[$this->system_type] ?? '';
    }

    public function getCycleValue(): string
    {
        return self::$cycles[$this->cycle] ?? '';
    }

    public function getSyncStatusValue(): string
    {
        return self::$sync_status[$this->sync_status] ?? '';
    }

    public function getStatusValue(): string
    {
        return self::$status[$this->status] ?? '';
    }
}